﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Word;

namespace ecdl.demo.model.word {
    public class WordDocumentSaver {
        public void SaveDocument(string fullPath) {
            try {
                Application app = (Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");
               
                if (app != null) {
                    foreach (Document d in app.Documents) {

                        if (d.FullName.ToLower() == fullPath.ToLower()) {
                            d.Save();
                        }
                    }
                }
            } catch(Exception e) {
                Console.WriteLine(e);
            }
        }
    }
}
